package com.kx.decorator_mode;

/**
 * Created on 2021/10/15.
 *
 * @author KaiXuan Xiao
 */
///////////////////////////////////////////////////////////////////////////
    //              <<3. 装饰者模式-可以换风格的服饰系统>>
    // 定义Component衣服接口对象,
    // 实现ComponentImpl, 并重写operation方法执行具体的操作,
    // 定义抽象衣服父类Decorator, 实现Component接口, 定义Component属性并提供set方法, 并重写operation方法如果component属性不为空, 则去执行Component的operation方法.
    // 定义各种衣服的具体类, 继承Decorator, 重写operation方法, 并去调用父类的operation方法.
    // 把各个对象new出来, 依次装饰进行, 整个装饰者模式完成.
///////////////////////////////////////////////////////////////////////////
public class App {
    public static void main(String[] args) {
        ComponentImpl component = new ComponentImpl("kx");

        System.out.println("第一套服装搭配: ");
        SweatPantsDecorator sweatPantsDecorator = new SweatPantsDecorator();
        SweaterDecorator sweaterDecorator = new SweaterDecorator();
        LooseCoatDecorator looseCoatDecorator = new LooseCoatDecorator();
        BootsDecorator bootsDecorator = new BootsDecorator();

        sweatPantsDecorator.setComponent(component);
        sweaterDecorator.setComponent(sweatPantsDecorator);
        looseCoatDecorator.setComponent(sweaterDecorator);
        bootsDecorator.setComponent(looseCoatDecorator);
        bootsDecorator.operation();
        component.show();

        /*System.out.println("第二套服装搭配: ");
        SweatPantsDecorator sweatPantsDecorator = new SweatPantsDecorator();
        SweaterDecorator sweaterDecorator = new SweaterDecorator();
        LooseCoatDecorator looseCoatDecorator = new LooseCoatDecorator();
        BootsDecorator bootsDecorator = new BootsDecorator();

        sweatPantsDecorator.setComponent(component);
        sweaterDecorator.setComponent(sweatPantsDecorator);
        looseCoatDecorator.setComponent(sweaterDecorator);
        bootsDecorator.setComponent(looseCoatDecorator);
        bootsDecorator.operation();
        component.show();*/
    }
}
